//
//  WATFNavView.swift
//  WiFiFaster
//
//  Created by one on 2023/12/28.
//

import UIKit

class WATFNavView: UIView {
    override init(frame: CGRect) {
        super.init(frame: CGRect(x: 0, y: 0, width: watf_SCREEN_WIDTH, height: WATFCommon.watf_navHegiht))
        watf_initViews()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func watf_initViews()  {
        addSubview(watf_leftButton)
        addSubview(watf_titleLabel)
        
        watf_leftButton.snp.makeConstraints { make in
            make.bottom.equalToSuperview().offset(-10)
            make.left.equalToSuperview().offset(20)
            make.size.equalTo(24)
        }
        watf_titleLabel.snp.makeConstraints { make in
            make.centerY.equalTo(watf_leftButton.snp.centerY)
            make.centerX.equalToSuperview()
        }
    }
    
    @objc func watf_buttonClick(sender: UIButton) {
        if sender == watf_leftButton {
            if (watf_leftBlock != nil) {
                watf_leftBlock?()
                return
            }
            watf_viewGetVController?.navigationController?.popViewController(animated: true)
            return
        }
    }
    
    var watf_leftBlock:(()->())?
    
    lazy var watf_leftButton: UIButton = {
        let watf_leftButton = UIButton()
        watf_leftButton.setImage(UIImage(named: "watf_nav_back"), for: .normal)
        watf_leftButton.addTarget(self, action: #selector(watf_buttonClick(sender:)), for: .touchUpInside)
        return watf_leftButton
    }()
    
    lazy var watf_titleLabel: UILabel = {
        let watf_titleLabel = UILabel()
        watf_titleLabel.font = UIFont.systemFont(ofSize: 16)
        watf_titleLabel.textColor = WATFCommon.watf_getHXColorValue(rgb: 0xFFFFFF)
        return watf_titleLabel
    }()
    
}
